package com.bawei.day14_service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

import androidx.annotation.Nullable;

public class MyService2 extends Service {
    private static final String TAG = "ytx";
    //TODO 2：返回MyBinder对象
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.d(TAG, "onBind: ");
        return new MyBinder();
    }
    //TODO 1：定义binder类，里面封装要调用的方法
    class MyBinder extends Binder{


        public void play(){
            Log.d(TAG, "play: ");
        }

        public void next(){
            Log.d(TAG, "next: ");
        }

        public void pre(){
            Log.d(TAG, "pre: ");
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d(TAG, "onCreate: ");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy: ");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d(TAG, "onStartCommand: ");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.d(TAG, "onUnbind: ");
        return super.onUnbind(intent);
    }
}
